<?php 
$type=$this->input->get('type');
$content=$model;
$collection=$model->collection;
$title='Kategorien an '.$model->title.' aus Collection '.$collection->title.' hinzufügen';
echo '<div class="contentheader">'.$title.' </div>';
if($model->id!=0){
	echo $formheader;
}
$hidden['formtype']="addcategories";
echo form::open(NULL, array(),$hidden);
echo form::open_fieldset();

$cats=$collection->contcategory;
$existing_cats=$model->contcategories->select_list('id','title');


foreach($cats as $cat){
	$hascat='';
	if(array_key_exists($cat->id, $existing_cats)){
		$hascat=1;
	}
	if($cat->type==$type){
		echo myform::checkbox2('contcatarray[]', $cat->id, $cat->title, $hascat);
	}else{
		if($hascat){
			echo form::hidden('contcatarray[]', $cat->id);
		}
	}
}

echo form::close_fieldset();
echo myform::submit_small();
echo form::close();
?>